/*
 * PagoscomerciosFijosFrame.java
 *
 * Created on 13 de abril de 2008, 11:44 AM
 */
package org.vehiculos.secuestros;

import org.mybeans.Sesion;
 
import org.mybeans.ComerciosBeans;
import org.mybeans.ContribuyentesBeans;
import org.mybeans.RegimenBeans;
import org.mybeans.VehiculosBeans;


import org.vehiculos.busquedas.VehiculosBusquedaSecuestradosFrame;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author  avbravo
 */
public class VehiculosSecuestroLiberarFrame extends javax.swing.JFrame {

    boolean focoVehiculo = false;
    boolean focoImpuesto = false;
    String reportSource;
    String reportDest;
    JTextField fieldPago;
    JTextField fieldSaldo;
    JTextField fieldExoneracion;
    Sesion sesion;
    ComerciosBeans comerciosBeans;
    ContribuyentesBeans contribuyentesBeans;
    RegimenBeans regimenBeans;
    VehiculosBeans vehiculosBeans;
    int fila = -1;
    DefaultTableModel modelo;
    private int AnioRecibo;
    private int NumeroMes;
    String IdVehiculo;
    String TipoId = "vehiculos";
    private String idRegimen;
    String sql;
    double Pago = 0;
    double Exoneracion = 0;
    double Valor = 0.0;
    double Saldo = 0.0;
    double SaldoAnterior = 0.0;
    int IdRecibo = 0;
    Double TotalPagado = 0.0;
    Double TotalExonerado = 0.0;
    String idExoneracion = "";
    Double Deuda;
    boolean TieneExoneracion = false;
    boolean TieneAlgunRegistroMoroso = false;
    String Estatus;
    int n;
    int paginas;
    String NoPaga = "no";
    String Motivo = "";
    boolean seleccion = false;
    String idEntidad;
    String Placa, residenciaOld = "", vendedor = "";
    String Juzgado, idJuzgado, Oficio, Auto;
    int IdSecuestroEspera, contadorSecuestros = 0;

    /** Creates new form */
    public VehiculosSecuestroLiberarFrame() {
        initComponents();
        sesion = new Sesion();
        /*
         * Fondo
         */

         
         
         

        jPanelFondo.setOpaque(false);
        setContentPane(jPanelFondo);
        /*
         * fondo
         */

        regimenBeans = new RegimenBeans();
        vehiculosBeans = new VehiculosBeans();
        comerciosBeans = new ComerciosBeans();
        contribuyentesBeans = new ContribuyentesBeans();

        java.util.Calendar ca = java.util.Calendar.getInstance();
        java.sql.Date mydate = new java.sql.Date(ca.getTimeInMillis());
        jFormattedTextFieldFecha.setValue(mydate);
        sesion.setTipoId("vehiculos");

        this.AnioRecibo = ca.get(java.util.Calendar.YEAR);
        NumeroMes = ca.get(java.util.Calendar.MONTH);


        jXDatePickerFechaFinSecuestro.setDate(mydate);
        jXDatePickerFechaFinSecuestro.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
        sesion.setAnioRecibo(AnioRecibo);
        sesion.setNumeroMesRecibo(NumeroMes);
        //





        if (sesion.getPlaca() == null || sesion.getPlaca().equals("")) {
        } else {
            jTextFieldPlaca.setText(sesion.getPlaca());
            CargarVehiculos();
        }





    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelFondo = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jFormattedTextFieldFecha = new javax.swing.JFormattedTextField();
        jButtonRegresar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldPlaca = new javax.swing.JTextField();
        jButtonBuscarVehiculos = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldMarca = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldModelo = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldColor = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        jRadioButtonContribuyente = new javax.swing.JRadioButton();
        jRadioButtonComercio = new javax.swing.JRadioButton();
        jLabel9 = new javax.swing.JLabel();
        jTextFieldId = new javax.swing.JTextField();
        jTextFieldDueno = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jButtonLiberar = new javax.swing.JButton();
        jButtonLimpiar = new javax.swing.JButton();
        jButtonRegresar2 = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jTextFieldNoOficio = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jXDatePickerFechaFinSecuestro = new org.jdesktop.swingx.JXDatePicker();
        jScrollPane1 = new javax.swing.JScrollPane();
        jXTable1 = new org.jdesktop.swingx.JXTable();
        jTextFieldEntidad = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("LIBERAR SECUESTROS DE  VEHICULOS");
        addWindowFocusListener(new java.awt.event.WindowFocusListener() {
            public void windowGainedFocus(java.awt.event.WindowEvent evt) {
                formWindowGainedFocus(evt);
            }
            public void windowLostFocus(java.awt.event.WindowEvent evt) {
            }
        });

        jPanelFondo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanelFondo.setOpaque(false);
        jPanelFondo.setPreferredSize(new java.awt.Dimension(1007, 800));

        jLabel3.setText("Fecha");

        jFormattedTextFieldFecha.setEditable(false);
        jFormattedTextFieldFecha.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yyyy"))));
        jFormattedTextFieldFecha.setToolTipText("Fecha");
        jFormattedTextFieldFecha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFormattedTextFieldFechaActionPerformed(evt);
            }
        });

        jButtonRegresar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/regresar.jpeg"))); // NOI18N
        jButtonRegresar.setToolTipText("Regresar");
        jButtonRegresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegresarActionPerformed(evt);
            }
        });

        jLabel4.setText("Placa");

        jTextFieldPlaca.setColumns(35);
        jTextFieldPlaca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldPlacaActionPerformed(evt);
            }
        });

        jButtonBuscarVehiculos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/search.png"))); // NOI18N
        jButtonBuscarVehiculos.setToolTipText("Buscar");
        jButtonBuscarVehiculos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarVehiculosActionPerformed(evt);
            }
        });

        jLabel5.setText("Marca");

        jTextFieldMarca.setEditable(false);

        jLabel7.setText("Modelo");

        jTextFieldModelo.setEditable(false);

        jLabel8.setText("Color");

        jTextFieldColor.setEditable(false);

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel5.setEnabled(false);

        jLabel16.setText("Dueño ");

        jRadioButtonContribuyente.setSelected(true);
        jRadioButtonContribuyente.setText("Contribuyente");
        jRadioButtonContribuyente.setEnabled(false);
        jRadioButtonContribuyente.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonContribuyenteMouseClicked(evt);
            }
        });

        jRadioButtonComercio.setText("Comercio");
        jRadioButtonComercio.setEnabled(false);
        jRadioButtonComercio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonComercioMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jLabel16)
                .addGap(18, 18, 18)
                .addComponent(jRadioButtonContribuyente)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButtonComercio)
                .addContainerGap(49, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel16)
            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jRadioButtonComercio)
                .addComponent(jRadioButtonContribuyente))
        );

        jLabel9.setText("Identificador");

        jTextFieldId.setEditable(false);

        jTextFieldDueno.setEditable(false);

        jLabel10.setText("Dueño");

        jButtonLiberar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/save.png"))); // NOI18N
        jButtonLiberar.setToolTipText("Imprime el Liberar");
        jButtonLiberar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLiberarActionPerformed(evt);
            }
        });

        jButtonLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/escoba.png"))); // NOI18N
        jButtonLimpiar.setToolTipText("Limpiar");
        jButtonLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimpiarActionPerformed(evt);
            }
        });

        jButtonRegresar2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/regresar.jpeg"))); // NOI18N
        jButtonRegresar2.setToolTipText("Regresar");
        jButtonRegresar2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegresar2ActionPerformed(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLabel13.setText("Secuestro");

        jLabel14.setText("No. Oficio");

        jLabel19.setText("Entidad");

        jLabel17.setText("Fecha Liberacion");

        jXTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "placa", "no oficio", "fechaoficio", "no auto", "juzgado", "entidad", "recibo"
            }
        ));
        jXTable1.setHorizontalScrollEnabled(true);
        jScrollPane1.setViewportView(jXTable1);

        javax.swing.GroupLayout jPanelFondoLayout = new javax.swing.GroupLayout(jPanelFondo);
        jPanelFondo.setLayout(jPanelFondoLayout);
        jPanelFondoLayout.setHorizontalGroup(
            jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFondoLayout.createSequentialGroup()
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jLabel19)
                                .addGap(34, 34, 34))
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addGap(18, 18, 18)))
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldNoOficio, javax.swing.GroupLayout.PREFERRED_SIZE, 390, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldEntidad, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jXDatePickerFechaFinSecuestro, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(jButtonLiberar, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonRegresar2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel13))
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addGap(54, 54, 54))
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jLabel9)
                                .addGap(18, 18, 18)))
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldDueno, javax.swing.GroupLayout.PREFERRED_SIZE, 411, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldId, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel7)
                            .addComponent(jLabel8)
                            .addComponent(jLabel4))
                        .addGap(30, 30, 30)
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jTextFieldPlaca, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(23, 23, 23)
                                .addComponent(jButtonBuscarVehiculos, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(31, 31, 31)
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jFormattedTextFieldFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonRegresar, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jTextFieldMarca, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldColor, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldModelo, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(169, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelFondoLayout.createSequentialGroup()
                .addContainerGap(24, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 738, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanelFondoLayout.setVerticalGroup(
            jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFondoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(jFormattedTextFieldFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonRegresar, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldPlaca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonBuscarVehiculos))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextFieldMarca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldModelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextFieldColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel10)
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldDueno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(12, 12, 12)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldNoOficio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(jTextFieldEntidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(jXDatePickerFechaFinSecuestro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jButtonLimpiar, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
                    .addComponent(jButtonLiberar, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonRegresar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(21, 21, 21))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelFondo, javax.swing.GroupLayout.DEFAULT_SIZE, 778, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelFondo, javax.swing.GroupLayout.DEFAULT_SIZE, 607, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButtonRegresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegresarActionPerformed

    this.dispose();
}//GEN-LAST:event_jButtonRegresarActionPerformed

private void jFormattedTextFieldFechaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFormattedTextFieldFechaActionPerformed
}//GEN-LAST:event_jFormattedTextFieldFechaActionPerformed

private void jButtonRegresar2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegresar2ActionPerformed

    dispose();
}//GEN-LAST:event_jButtonRegresar2ActionPerformed

private void jButtonLiberarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLiberarActionPerformed


    try {
        if (ValidarEntradas() == false) {
            return;
        }


        /*
         * guardar el recibo
         * 
         */
        IdVehiculo = vehiculosBeans.getIdVehiculo();
        java.util.Date myFecha = (java.util.Date) jFormattedTextFieldFecha.getValue();
        java.sql.Date date = new java.sql.Date(myFecha.getTime());


        GuardarLiberacionSecuestro();

        jButtonLiberar.setEnabled(false);

        String sql = "select vehiclessecuestroespera.*,juzgado.juzgado, entidad.entidad " +
                " from vehiclessecuestroespera, juzgado, entidad " +
                " where vehiclessecuestroespera.activo='si' " +
                " and vehiclessecuestroespera.idvehiculo ='" + vehiculosBeans.getIdVehiculo() + "' " +
                " and vehiclessecuestroespera.idmunicipio='" + sesion.getIdmunicipio() + "' " +
                " and vehiclessecuestroespera.procesado='no' " +
                " and vehiclessecuestroespera.idjuzgado = juzgado.IDJUZGADO " +
                " and juzgado.activo='si' " +
                " and juzgado.idmunicipio ='" + sesion.getIdmunicipio() + "' " +
                " and entidad.IDENTIDAD = vehiclessecuestroespera.IDENTIDAD " +
                " and entidad.activo ='si' " +
                " and entidad.IDMUNICIPIO = '" + sesion.getIdmunicipio() + "' " +
                " order by placa, idsecuestroespera ";

        CargarTodosRegistros(sql);

    } catch (Exception ex) {
        sesion.MostrarMensajeError("Error ", "Metodo:  jButtonImprimirActionPerformed()\nError:\n " + ex.getMessage().toString());
    }

}//GEN-LAST:event_jButtonLiberarActionPerformed

private void jButtonLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimpiarActionPerformed

    Limpiar();
    LimpiarTable();

}//GEN-LAST:event_jButtonLimpiarActionPerformed

    private void Actualizar() {
        try {

            jTextFieldPlaca.setText(vehiculosBeans.getPlaca());
            this.Placa = vehiculosBeans.getPlaca();
            jTextFieldMarca.setText(vehiculosBeans.getMarca());
            jTextFieldModelo.setText(vehiculosBeans.getModelo());
            jTextFieldColor.setText(vehiculosBeans.getColor());
            jTextFieldId.setText(vehiculosBeans.getId());
            jTextFieldDueno.setText(vehiculosBeans.getDueno());
            this.vendedor = vehiculosBeans.getDueno();

            String TipoId = vehiculosBeans.getTipoId();
            String idOld = vehiculosBeans.getId();
            TipoId = TipoId.toLowerCase();
            if (TipoId.equals("contribuyentes")) {
                jRadioButtonContribuyente.setSelected(true);
                jRadioButtonComercio.setSelected(false);

            } else {
                if (TipoId.equals("comercios")) {
                    jRadioButtonContribuyente.setSelected(false);
                    jRadioButtonComercio.setSelected(true);

                }
            }


            String sql = "select vehiclessecuestroespera.*,juzgado.juzgado, entidad.entidad " +
                    " from vehiclessecuestroespera, juzgado, entidad " +
                    " where vehiclessecuestroespera.activo='si' " +
                    " and vehiclessecuestroespera.idvehiculo ='" + vehiculosBeans.getIdVehiculo() + "' " +
                    " and vehiclessecuestroespera.idmunicipio='" + sesion.getIdmunicipio() + "' " +
                    " and vehiclessecuestroespera.procesado='no' " +
                    " and vehiclessecuestroespera.idjuzgado = juzgado.IDJUZGADO " +
                    " and juzgado.activo='si' " +
                    " and juzgado.idmunicipio ='" + sesion.getIdmunicipio() + "' " +
                    " and entidad.IDENTIDAD = vehiclessecuestroespera.IDENTIDAD " +
                    " and entidad.activo ='si' " +
                    " and entidad.IDMUNICIPIO = '" + sesion.getIdmunicipio() + "' " +
                    " order by placa, idsecuestroespera ";

            CargarTodosRegistros(sql);
jButtonLiberar.setEnabled(true);
            repaint();

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Actualizar()\nError " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }

private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowGainedFocus
    // TODO add your handling code here:
    try {


        if (focoVehiculo) {
            Actualizar();
        }


        focoImpuesto = false;
        focoVehiculo = false;
    } catch (Exception ex) {
        sesion.MostrarMensajeError("Error ", "formWindowGainedFocus()\nError " + ex.getMessage().toString());
    }
}//GEN-LAST:event_formWindowGainedFocus

private void jTextFieldPlacaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldPlacaActionPerformed

    CargarVehiculos();
}//GEN-LAST:event_jTextFieldPlacaActionPerformed

private void jButtonBuscarVehiculosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarVehiculosActionPerformed

    VehiculosBusquedaSecuestradosFrame vehiculosBusquedaSecuestradosFrame = new VehiculosBusquedaSecuestradosFrame();
    vehiculosBusquedaSecuestradosFrame.setLocationRelativeTo(null);
    vehiculosBusquedaSecuestradosFrame.setVisible(true);
    focoVehiculo = true;
}//GEN-LAST:event_jButtonBuscarVehiculosActionPerformed

private void jRadioButtonContribuyenteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonContribuyenteMouseClicked
}//GEN-LAST:event_jRadioButtonContribuyenteMouseClicked

private void jRadioButtonComercioMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonComercioMouseClicked
}//GEN-LAST:event_jRadioButtonComercioMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new VehiculosSecuestroLiberarFrame().setVisible(true);
            }
        });
    }

    /*
     * 
     *verifica si ya se pago la placa para este año 
     * 
     */
    private void LimpiarComercios() {
        jTextFieldPlaca.setText("");
        jTextFieldMarca.setText("");
        jTextFieldModelo.setText("");
        jTextFieldColor.setText("");
        jTextFieldId.setText("");
        jTextFieldDueno.setText("");
    }

    private void Limpiar() {
        try {

            jTextFieldNoOficio.setText("");
jTextFieldEntidad.setText("");
            LimpiarRegimen();
            LimpiarComercios();

        } catch (Exception ex) {
            sesion.MostrarMensajeError("Error ", "Limpiar()\n " + ex.getMessage().toString());
        }
    }

    public void LimpiarRegimen() {
        //jTextFieldIdRegimen.setText("");
    }

    /*
     *
     * Cargar exoneraciones
     *
     */
    private boolean ValidarEntradas() {
        try {


            IdVehiculo = this.jTextFieldPlaca.getText();

            if (IdVehiculo == null || IdVehiculo.equals("")) {
                JOptionPane.showMessageDialog(this, "No ha seleccionado un comercio", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                jTextFieldPlaca.requestFocus();
                return false;
            }


            String Marca = this.jTextFieldMarca.getText();
            if (Marca == null || Marca.equals("")) {
                JOptionPane.showMessageDialog(this, "No ha seleccionado ningun vehiculo", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                jTextFieldPlaca.requestFocus();
                return false;
            }







            String sFecha = jFormattedTextFieldFecha.getText();
            if (sFecha == null || sFecha.equals("")) {
                JOptionPane.showMessageDialog(this, "seleccione la fecha ", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                jFormattedTextFieldFecha.requestFocus();
            }

            java.util.Date FechaDate = jXDatePickerFechaFinSecuestro.getDate();
            java.sql.Date FechaInicioSecuestro = new java.sql.Date(FechaDate.getTime());
            if (FechaInicioSecuestro == null) {
                JOptionPane.showMessageDialog(this, "Ingrese la fecha de inicio de secuestro...", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                jXDatePickerFechaFinSecuestro.requestFocus();
                return false;
            }


            sesion.con.close();




            return true;
        } catch (Exception ex) {
            sesion.MostrarMensajeError("Error ", "ValidarEntradas()\n " + ex.getMessage().toString());
        }
        return false;
    }

    private void CargarVehiculos() {

        try {
            String Placa = this.jTextFieldPlaca.getText();
            if (Placa == null || Placa.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese la placa del vehiculo", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            vehiculosBeans.setPlaca(Placa);

            if (vehiculosBeans.ConsultarPorPlaca() == true) {

                if (vehiculosBeans.getPlaca() == null || vehiculosBeans.getPlaca().equals("")) {
                    JOptionPane.showMessageDialog(this, "Este vehiculo no tiene asiganda una placa...", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                    return;
                }

                jTextFieldId.setText(vehiculosBeans.getId());
                //-----------------------------------
                //----   Verifica el estatus     ----
                //-----------------------------------

                if (vehiculosBeans.getSecuestrado().equals("no")) {

                    JOptionPane.showMessageDialog(this, "Este vehiculo no esta secuestrado ", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                    return;
                }




                vehiculosBeans.setTipoId(vehiculosBeans.getTipoId().toLowerCase());
                if (vehiculosBeans.getTipoId().equals("contribuyentes")) {
                    ContribuyentesCargar();
                    jRadioButtonContribuyente.setSelected(true);
                    jRadioButtonComercio.setSelected(false);
                } else {
                    if (vehiculosBeans.getTipoId().equals("comercios")) {
                        ComerciosCargar();
                        jRadioButtonContribuyente.setSelected(false);
                        jRadioButtonComercio.setSelected(true);
                    }
                }

                Actualizar();

            }

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "CargarVehiculos()\nError " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }


    }

    private void ContribuyentesCargar() {
        try {
            String cedula = this.jTextFieldId.getText();
            if (cedula == null || cedula.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese la cedula del contribuyente", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            if (sesion.Conectar() == false) {
                JOptionPane.showMessageDialog(this, "No se pudo establecer la conexion", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }

            String sqlquery = "select * from contribuyentes where idmunicipio = ? and cedula = ?";
            PreparedStatement psquery = sesion.con.prepareStatement(sqlquery);
            psquery.setString(1, sesion.getIdmunicipio());
            psquery.setString(2, cedula);
            ResultSet rs = psquery.executeQuery();
            rs.next();
            int x = rs.getRow();
            if (x == 0) {
                JOptionPane.showMessageDialog(this, "No existen registros de contribuyentes con esa cedula", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            String activo = rs.getString("activo");
            if (activo.equals("no")) {
                JOptionPane.showMessageDialog(this, "Este registro esta inactivo", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            contribuyentesBeans.setCedula(cedula);
            contribuyentesBeans.setContribuyente(rs.getString("contribuyente"));
            contribuyentesBeans.setIdSeguroSocial(rs.getString("idsegurosocial"));
            contribuyentesBeans.setOcupacion(rs.getString("ocupacion"));
            contribuyentesBeans.setNacionalidad(rs.getString("nacionalidad"));
            contribuyentesBeans.setIdMunicipio(rs.getString("idmunicipio"));
            contribuyentesBeans.setIdCorregimiento(rs.getString("idcorregimiento"));
            contribuyentesBeans.setDomicilio(rs.getString("domicilio"));
            contribuyentesBeans.setCasa(rs.getString("casa"));
            contribuyentesBeans.setTelefono(rs.getString("telefono"));
            contribuyentesBeans.setApartadoPostal(rs.getString("apartadopostal"));
            contribuyentesBeans.setEmail(rs.getString("email"));
            contribuyentesBeans.setObservacion(rs.getString("observacion"));
            contribuyentesBeans.setIdMunicipioVive(rs.getString("idmunicipiovive"));
            contribuyentesBeans.setIdCorregimientoVive(rs.getString("idcorregimientovive"));
            contribuyentesBeans.setActivo(rs.getString("activo"));
            contribuyentesBeans.setFoto(rs.getString("foto"));



            if (contribuyentesBeans.getContribuyente() == null || contribuyentesBeans.getContribuyente().equals("")) {
                JOptionPane.showMessageDialog(this, "El contribuyente esta en blanco", "Mensaje", JOptionPane.WARNING_MESSAGE);
                return;
            }

            jTextFieldDueno.setText(contribuyentesBeans.getContribuyente());
            vehiculosBeans.setDueno(contribuyentesBeans.getContribuyente());

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "ContribuyentesCargar()\nError " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }

    private void ComerciosCargar() {
        try {
            String IdComercio = this.jTextFieldId.getText();
            if (IdComercio == null || IdComercio.equals("")) {
                JOptionPane.showMessageDialog(this, "Ingrese el codigo del comercio", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            if (sesion.Conectar() == false) {
                JOptionPane.showMessageDialog(this, "No se pudo establecer la conexion", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }

            String sqlquery = "select comercios.*, contribuyentes.contribuyente from comercios, contribuyentes where comercios.idmunicipio = ? and comercios.idcomercio = ? and comercios.cedula = contribuyentes.cedula";
            PreparedStatement psquery = sesion.con.prepareStatement(sqlquery);
            psquery.setString(1, sesion.getIdmunicipio());
            psquery.setString(2, IdComercio);
            ResultSet rs = psquery.executeQuery();
            rs.next();
            int x = rs.getRow();
            if (x == 0) {
                JOptionPane.showMessageDialog(this, "No existen registros de comercios con ese codigo", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }

            String comercio = rs.getString("comercio");
            String cedula = rs.getString("cedula");
            String contribuyente = rs.getString("contribuyente");
            String Ruc = rs.getString("ruc");
            String Descripcion = rs.getString("descripcion");
            String Direccion = rs.getString("direccion");
            String IdCorregimiento = rs.getString("idcorregimiento");
            String Telefono = rs.getString("telefono");
            String Hipotecado = rs.getString("hipotecado");
            String Bajado = rs.getString("bajado");
            String Traspaso = rs.getString("traspaso");
            String Estatal = rs.getString("estatal");
            String Secuestrado = rs.getString("secuestrado");
            String Activo = rs.getString("activo");

            jTextFieldDueno.setText(comercio);

            if (comercio == null || comercio.equals("")) {
                JOptionPane.showMessageDialog(this, "El comercio esta en blanco", "Mensaje", JOptionPane.WARNING_MESSAGE);
                return;
            }

            comerciosBeans.setIdComercio(IdComercio);
            comerciosBeans.setComercio(comercio);
            comerciosBeans.setCedula(cedula);
            comerciosBeans.setContribuyente(contribuyente);
            comerciosBeans.setRuc(Ruc);
            comerciosBeans.setDescripcion(Descripcion);
            comerciosBeans.setDireccion(Direccion);
            comerciosBeans.setIdCorregimiento(IdCorregimiento);
            comerciosBeans.setTelefono(Telefono);
            comerciosBeans.setHipotecado(Hipotecado);
            comerciosBeans.setBajado(Bajado);
            comerciosBeans.setTraspaso(Traspaso);
            comerciosBeans.setEstatal(Estatal);
            comerciosBeans.setSecuestrado(Secuestrado);
            comerciosBeans.setActivo(Activo);
            vehiculosBeans.setDueno(comerciosBeans.getComercio());
            repaint();

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "ComerciosGuardar()\nError " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }

    private void GuardarLiberacionSecuestro() {
        try {

            if (sesion.Conectar() == false) {
                JOptionPane.showMessageDialog(this, "No se pudo establecer la conexion", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }

            if (contadorSecuestros == 1) {


                String sql = "update  vehicles set secuestrado='no' where idmunicipio = ? and idvehiculo = ? and activo='si'";


                PreparedStatement prest1 = sesion.con.prepareStatement(sql);
                prest1.setString(1, sesion.getIdmunicipio()); //placa
                prest1.setInt(2, Integer.parseInt(this.IdVehiculo));

                int count1 = prest1.executeUpdate();
            }



            java.util.Date FechaDate = jXDatePickerFechaFinSecuestro.getDate();
            java.sql.Date FechaFinSecuestro = new java.sql.Date(FechaDate.getTime());
            if (FechaFinSecuestro == null) {
                JOptionPane.showMessageDialog(this, "Ingrese la fecha de liberacion  de secuestro...", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                jXDatePickerFechaFinSecuestro.requestFocus();
                return;
            }
            sql = "update vehiclessecuestroespera set procesado ='si' ,fechafinsecuestro =?  where idmunicipio=? and idsecuestroespera=? and activo ='si'";
            PreparedStatement prest = sesion.con.prepareStatement(sql);

            prest.setDate(1, FechaFinSecuestro);
            prest.setString(2, sesion.getIdmunicipio());
            prest.setInt(3, this.IdSecuestroEspera); //



            int count = prest.executeUpdate();
            String mensaje;
            if (contadorSecuestros == 1) {
                mensaje = "Se libero el secuestro exitosamente";
            } else {
                mensaje = "Se libero el secuestro\n Pero este vehiculo tiene otros secuestros en espera";
            }
            JOptionPane.showMessageDialog(this, mensaje, "Mensaje", JOptionPane.INFORMATION_MESSAGE);

            LimpiarTable();
            sesion.con.close();


        } catch (Exception ex) {
            System.out.println("Error" + ex);
            JOptionPane.showMessageDialog(this, "GuardarLiberacionSecuestro()\nError " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }

    }

    public void CargarTodosRegistros(String sql) {
        try {
            //  LimpiarTable();
            if (sesion.Conectar() == false) {
                JOptionPane.showMessageDialog(this, "No se pudo establecer la conexion", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return;
            }

            PreparedStatement psquery = sesion.con.prepareStatement(sql);
            ResultSet rs = psquery.executeQuery();

            modelo = new DefaultTableModel();
            // Creamos las columnas.
            modelo.addColumn("placa");
            modelo.addColumn("No Oficio");
            modelo.addColumn("fecha oficio");
            modelo.addColumn("No Auto");
            modelo.addColumn("Juzgado");
            modelo.addColumn("Entidad");
            modelo.addColumn("Recibo");
            contadorSecuestros = 0;
// Bucle para cada resultado en la consulta
            while (rs.next()) {
                // Se crea un array que será una de las filas de la tabla.
                contadorSecuestros++;
                Object[] fila = new Object[7]; // Hay tres columnas en la tabla

                fila[0] = rs.getString("placa");

                String oficio = rs.getString("oficio");
                fila[1] = oficio;
                Date fecha = rs.getDate("fechaoficio");
                Format formatter;
                formatter = new SimpleDateFormat("dd/MM/yyyy");
                String s = formatter.format(fecha);
                fila[2] = s;
                fila[3] = rs.getString("noauto");
                fila[4] = rs.getString("juzgado");

                String entidad = rs.getString("entidad");
                fila[5] = entidad;
                fila[6] = rs.getString("idrecibo");
                if (contadorSecuestros == 1) {
                    this.IdSecuestroEspera = rs.getInt("idsecuestroespera");
                    jTextFieldNoOficio.setText(oficio);
                    jTextFieldEntidad.setText(entidad);

                }

                modelo.addRow(fila);

            }
            this.jXTable1.setModel(modelo);
            jXTable1.setVisible(true);
            //aris++
            this.jXTable1.addMouseListener(new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {

                    fila = jXTable1.rowAtPoint(e.getPoint());
                    int columna = jXTable1.columnAtPoint(e.getPoint());
                    if ((fila > -1) && (columna > -1)) {
//                      jTextFieldIdVehiculo.setText(String.valueOf(jTable1.getValueAt(fila, 0)));
                        //                    jTextFieldPlaca.setText(String.valueOf(jTable1.getValueAt(fila, 1)));

//                        CargarVehiculos();
                    }
                }
            });

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "CargarTodosRegistros()\nError " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }

    private void LimpiarTable() {
        try {

            boolean control = false;
            while (control == false) {
                int n = jXTable1.getRowCount();
                if (n <= 0) {
                    control = true;
                } else {
                    modelo.removeRow(0);
                }

            }//while
        } catch (Exception ex) {
            sesion.MostrarMensajeError("LimpiarTable()\nError ", "LimpiarTable()\n " + ex.getMessage().toString());
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonBuscarVehiculos;
    private javax.swing.JButton jButtonLiberar;
    private javax.swing.JButton jButtonLimpiar;
    private javax.swing.JButton jButtonRegresar;
    private javax.swing.JButton jButtonRegresar2;
    private javax.swing.JFormattedTextField jFormattedTextFieldFecha;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanelFondo;
    private javax.swing.JRadioButton jRadioButtonComercio;
    private javax.swing.JRadioButton jRadioButtonContribuyente;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextFieldColor;
    private javax.swing.JTextField jTextFieldDueno;
    private javax.swing.JTextField jTextFieldEntidad;
    private javax.swing.JTextField jTextFieldId;
    private javax.swing.JTextField jTextFieldMarca;
    private javax.swing.JTextField jTextFieldModelo;
    private javax.swing.JTextField jTextFieldNoOficio;
    private javax.swing.JTextField jTextFieldPlaca;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaFinSecuestro;
    private org.jdesktop.swingx.JXTable jXTable1;
    // End of variables declaration//GEN-END:variables
}
